#ifndef BATERRY_H
#define BATERRY_H

#include <QWidget>
#include <QPaintEvent>
#include <QPainter>
#include <QLinearGradient>
#include <QTimer>

class Baterry : public QWidget
{
    Q_OBJECT
public:
    explicit Baterry(QWidget *parent = 0);

    bool isForward;
    float step;
    float value;
    float currentValue;
    int borderWidth;
    int borderRadius;
    int headRadius;
    int alarmValue;
    int bgRadius;
    QTimer *timer;

    QRectF batteryRect;

    QColor borderColorStart;
    QColor borderColorEnd;
    QColor alarmColorStart;
    QColor alarmColorEnd;
    QColor normalColorStart;
    QColor normalColorEnd;

    void paintEvent(QPaintEvent *p);
    void drawBorder(QPainter *p);
    void drawBg(QPainter *p);
    void drawHead(QPainter *p);
public slots:
    void updateValue();
    void setValue(int value);
};

#endif // BATERRY_H
